(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  this.AdminAuthorEditView = (function(_super) {

    __extends(AdminAuthorEditView, _super);

    function AdminAuthorEditView() {
      return AdminAuthorEditView.__super__.constructor.apply(this, arguments);
    }

    AdminAuthorEditView.prototype.el = $('#content');

    AdminAuthorEditView.prototype.initialize = function() {
      AdminAuthorEditView.__super__.initialize.apply(this, arguments);
      this.model.bind("change", this.render);
      return this.model.fetch();
    };

    AdminAuthorEditView.prototype.render = function() {
      var _this = this;
      return this.GetTemplate(SiteMap.Admin.Authors.EditTemplate, function(compiledTemplate) {
        return $(_this.el).html(compiledTemplate(_this.model.toJSON()));
      });
    };

    AdminAuthorEditView.prototype.events = {
      "click .buttons>button.save": "save",
      "click .buttons>button.cancel": "cancel"
    };

    AdminAuthorEditView.prototype.save = function(e) {
      var data,
        _this = this;
      e.preventDefault();
      Loading.Start();
      Messages.WriteMessage('Saving author.');
      data = this.$el.find("form.general").serialize();
      return $.post(this.model.url(), data, function(response) {
        if ((response.SuccessMessage != null) && response.SuccessMessage.length) {
          Messages.WriteSuccessMessage(response.SuccessMessage);
          return _this.Navigate(SiteMap.Admin.Authors.Listing, true);
        } else {
          Messages.WriteErrors(response.Errors);
          return Loading.Stop();
        }
      });
    };

    AdminAuthorEditView.prototype.cancel = function(e) {
      e.preventDefault();
      Loading.Start();
      Messages.Clear();
      return this.Navigate(SiteMap.Admin.Authors.Listing, true);
    };

    return AdminAuthorEditView;

  })(CustomView);

}).call(this);
